package flc.ast.dialog;

import android.content.Context;
import android.view.Gravity;
import android.view.View;

import androidx.annotation.NonNull;

import com.blankj.utilcode.util.FileUtils;
import com.blankj.utilcode.util.TimeUtils;

import flc.ast.R;
import flc.ast.databinding.DialogInfoStyleBinding;
import stark.common.basic.base.BaseSmartDialog;
import stark.common.basic.utils.MediaUtil;

public class InfoDialog extends BaseSmartDialog<DialogInfoStyleBinding> {
    public String videoPath;

    public InfoDialog(@NonNull Context context) {
        super(context);
    }

    @Override
    protected int getGravity() {
        return Gravity.BOTTOM;
    }

    @Override
    protected boolean canceledOnTouchOutside() {
        return true;
    }

    @Override
    protected int getLayoutId() {
        return R.layout.dialog_info_style;
    }

    @Override
    protected void initView(View view) {
        mDataBinding.tvLocation.setSelected(true);
        mDataBinding.tvFileName.setText(FileUtils.getFileName(videoPath));
        mDataBinding.tvLocation.setText(videoPath);
        mDataBinding.tvSize.setText(FileUtils.getSize(videoPath));
        mDataBinding.tvCreateTime.setText(TimeUtils.millis2String(FileUtils.getFileLastModified(videoPath), "yyyy年MM月dd日 HH:mm:ss"));
        mDataBinding.tvFormat.setText(FileUtils.getFileName(videoPath).substring(FileUtils.getFileName(videoPath).lastIndexOf(".") + 1));
        mDataBinding.tvResolution.setText(MediaUtil.getMediaMetadataInfo(videoPath).getWidth() + " x " + MediaUtil.getMediaMetadataInfo(videoPath).getHeight());
        mDataBinding.tvDuration.setText(TimeUtils.millis2String(MediaUtil.getDuration(videoPath), "mm:ss"));
    }
}
